package com.briup.recognition.service.impl;

import com.briup.recognition.bean.UserRole;
import com.briup.recognition.bean.UserRoleExample;
import com.briup.recognition.dao.UserRoleMapper;
import com.briup.recognition.service.IUserRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserRoleServiceImpl implements IUserRoleService {
    @Resource
    private UserRoleMapper userRoleMapper;

    @Override
    public List<UserRole> query() {
        UserRoleExample example=new UserRoleExample();

        return userRoleMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(UserRole userRole) {
        if (userRole.getId()!=null){
            userRoleMapper.updateByPrimaryKey(userRole);
        }else {
            userRoleMapper.insert(userRole);
        }
    }

    @Override
    public void deleteById(long id) {
        userRoleMapper.deleteByPrimaryKey(id);
    }
}
